﻿namespace Pyramid.Hardware.Operations
{
    using System.Collections.Generic;
    using System.Linq;
    using Pyramid.Hardware.Gates;

    public class NotOperation
        : Operation
    {
        private readonly IEnumerable<ILine> outputBus;
        private readonly ILine overflowFlag;

        public NotOperation(IEnumerable<ILine> inputBusA)
            : this(inputBusA, inputBusA)
        {
        }

        public NotOperation(IEnumerable<ILine> inputBusA, IEnumerable<ILine> inputBusB)
            : base(inputBusA, inputBusB)
        {
            this.outputBus = inputBusA.Select(line => (ILine)new NotGate(line)).ToArray();
            this.overflowFlag = new FixedInputLine(Trivalent.Unknown);
        }

        public override IEnumerable<ILine> OutputBus
        {
            get
            {
                return outputBus;
            }
        }

        public override ILine OverflowFlag
        {
            get
            {
                return this.overflowFlag;
            }
        }
    }
}
